package com.woniu.sharepark.leasesystem.tenant.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.sharepark.common.JsonResult;
import com.woniu.sharepark.leasesystem.common.pojo.OrderForm;
import com.woniu.sharepark.leasesystem.common.service.OrderFormService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author DELL
 * @date 2019/6/4 18:57
 * version v1.0
 */
@RequestMapping("tentant")
@Controller
public class TentantController {

    @Resource
    private OrderFormService orderFormService;



    @RequestMapping("/certifyCarAndIdCard")
    @ResponseBody
    public JsonResult certifyCarAndIdCard(){


        return null;
    }
    /**
    * 分页查询历史订单
    * @title selectConsumptionList
    * @param currentPage, pageSize, modelAndView
    * @return org.springframework.web.servlet.ModelAndView
    * @author DELL
    * @date 2019/6/8 20:52
    **/

    @RequestMapping("/ConsumptionList")
    @ResponseBody
    public ModelAndView selectConsumptionList(@RequestParam(value = "currentPage" ,defaultValue = "1" ,required = false) Integer currentPage,
                                              @RequestParam(value = "pageSize" ,defaultValue = "5",required = false) Integer pageSize,
                                              ModelAndView modelAndView){
        //模拟当前账户登陆
        Integer userId = 1;

        //查找当前用户历史订单信息
        List<OrderForm> orderForms = orderFormService.selectConsumptionList(currentPage,pageSize);
        PageInfo pageInfo = new PageInfo(orderForms);
        modelAndView.setViewName("跳往的页面");
        modelAndView.addObject("orderForms",pageInfo);

        return modelAndView;
    }


}
